-- scrap
-- created by limj
-- 道具描述：荣誉碎片

return {
    -- 获取道具描述
    getDesc = function(itemId, args, para)
        local petId     = args["pet_id"];
        local heroName  = PetM.query(petId, "name");
        local heroDesc  = PetM.query(petId, "desc");
        local exDesc    = "";
        local myPet     = PetM.getMyPet(petId);

        if myPet then
            -- 玩家已经招募了该冈布奥
            -- 取合成证书的需求数量
            local medalId   = PetM.getNextMedal(petId);
            if medalId then
                local medalName = ItemM.query(medalId, "name");
                local costAmount;
                local costInfo  = CompoundM.calcCost(CompoundM.getCompoundRule(medalId));
                for _, a in pairs(costInfo) do
                    if a[1] == 1 and a[2] == itemId then
                        costAmount = a[3];
                        break;
                    end
                end

                -- 取玩家拥有道具的数量
                local ownAmount = ItemM.getAmount(ME.user, itemId);
                exDesc = string.format(getLocStr("script_desc_scrap2"), medalName, ownAmount, costAmount);
            end
        else
            exDesc = string.format(getLocStr("script_desc_scrap3"), heroName);
            local gType = PetM.query(petId, "get_type");
            if gType == DUNGEON or gType == DUNGEON_EGG then
                local dungeonId = PetM.query(petId, "appear_dungeon");
                local dungeonName = DungeonAreaM.query(dungeonId, "name");
                if gType == DUNGEON then
                    exDesc = exDesc .. string.format(getLocStr("script_desc_scrap_dungeon"), dungeonName);
                else
                    exDesc = exDesc .. string.format(getLocStr("script_desc_scrap_dungeon_egg"), dungeonName);
                end
            elseif gType == EGG then
                if petId == 41 then
                    -- 勇者冈布奥特殊显示
                    exDesc = exDesc .. getLocStr("script_desc_scrap_egg1");
                else
                    exDesc = exDesc .. getLocStr("script_desc_scrap_egg2");
                end
            elseif gType == RARE then
                    exDesc = exDesc .. getLocStr("script_desc_scrap_rare1");
                if not FeatureItemM.isFeatureOpen("scaffold") then
                    exDesc = exDesc .. getLocStr("script_desc_scrap_rare2");
                end
            elseif gType == SKY then
                    exDesc = exDesc .. getLocStr("script_desc_scrap_sky1");
                if not NewAirShipM.isFinishGuide() then
                    exDesc = exDesc .. getLocStr("script_desc_scrap_sky2");
                end
            end
        end

        local desc = string.format("%s\n%s", heroDesc, exDesc);
        return desc;
    end,
};
